load("@build_bazel_rules_android//android:rules.bzl", "android_library")

licenses(["notice"])

package(default_visibility = ["//visibility:public"])

java_library(
    name = "streaming_aead_util",
    srcs = ["StreamingAeadUtil.java"],
    deps = ["//proto:common_java_proto"],
)

java_library(
    name = "streaming_aead_key_templates",
    srcs = ["StreamingAeadKeyTemplates.java"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager",
        ":aes_gcm_hkdf_streaming_key_manager",
        "//proto:aes_ctr_hmac_streaming_java_proto",
        "//proto:aes_gcm_hkdf_streaming_java_proto",
        "//proto:common_java_proto",
        "//proto:hmac_java_proto",
        "//proto:tink_java_proto",
    ],
)

java_library(
    name = "streaming_aead_config",
    srcs = ["StreamingAeadConfig.java"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager",
        ":aes_gcm_hkdf_streaming_key_manager",
        ":streaming_aead_wrapper",
        "//proto:config_java_proto",
        "//src/main/java/com/google/crypto/tink/config:tink_fips",
    ],
)

java_library(
    name = "seekable_byte_channel_decrypter",
    srcs = ["SeekableByteChannelDecrypter.java"],
    deps = [
        "//src/main/java/com/google/crypto/tink:primitive_set",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "@maven//:com_google_code_findbugs_jsr305",
    ],
)

java_library(
    name = "input_stream_decrypter",
    srcs = ["InputStreamDecrypter.java"],
    deps = [
        "//src/main/java/com/google/crypto/tink:primitive_set",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "@maven//:com_google_code_findbugs_jsr305",
    ],
)

java_library(
    name = "streaming_aead_helper",
    srcs = ["StreamingAeadHelper.java"],
    deps = [
        ":input_stream_decrypter",
        ":readable_byte_channel_decrypter",
        ":seekable_byte_channel_decrypter",
        "//src/main/java/com/google/crypto/tink:primitive_set",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
    ],
)

java_library(
    name = "streaming_aead_factory",
    srcs = ["StreamingAeadFactory.java"],
    deps = [
        ":streaming_aead_wrapper",
        "//src/main/java/com/google/crypto/tink:registry",
        "//src/main/java/com/google/crypto/tink:registry_cluster",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
    ],
)

java_library(
    name = "aes_gcm_hkdf_streaming_key_manager",
    srcs = ["AesGcmHkdfStreamingKeyManager.java"],
    deps = [
        ":streaming_aead_util",
        "//proto:aes_gcm_hkdf_streaming_java_proto",
        "//proto:common_java_proto",
        "//proto:tink_java_proto",
        "//src/main/java/com/google/crypto/tink:key_template",
        "//src/main/java/com/google/crypto/tink:key_type_manager",
        "//src/main/java/com/google/crypto/tink:registry",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "//src/main/java/com/google/crypto/tink/subtle:aes_gcm_hkdf_streaming",
        "//src/main/java/com/google/crypto/tink/subtle:random",
        "//src/main/java/com/google/crypto/tink/subtle:validators",
        "@com_google_protobuf//:protobuf_javalite",
    ],
)

java_library(
    name = "aes_ctr_hmac_streaming_key_manager",
    srcs = ["AesCtrHmacStreamingKeyManager.java"],
    deps = [
        ":streaming_aead_util",
        "//proto:aes_ctr_hmac_streaming_java_proto",
        "//proto:common_java_proto",
        "//proto:hmac_java_proto",
        "//proto:tink_java_proto",
        "//src/main/java/com/google/crypto/tink:key_template",
        "//src/main/java/com/google/crypto/tink:key_type_manager",
        "//src/main/java/com/google/crypto/tink:registry",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "//src/main/java/com/google/crypto/tink/subtle:aes_ctr_hmac_streaming",
        "//src/main/java/com/google/crypto/tink/subtle:random",
        "//src/main/java/com/google/crypto/tink/subtle:validators",
        "@com_google_protobuf//:protobuf_javalite",
    ],
)

java_library(
    name = "readable_byte_channel_decrypter",
    srcs = ["ReadableByteChannelDecrypter.java"],
    deps = [
        "//src/main/java/com/google/crypto/tink:primitive_set",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "//src/main/java/com/google/crypto/tink/subtle:rewindable_readable_byte_channel",
        "@maven//:com_google_code_findbugs_jsr305",
    ],
)

java_library(
    name = "streaming_aead_wrapper",
    srcs = ["StreamingAeadWrapper.java"],
    deps = [
        ":streaming_aead_helper",
        "//src/main/java/com/google/crypto/tink:primitive_set",
        "//src/main/java/com/google/crypto/tink:primitive_wrapper",
        "//src/main/java/com/google/crypto/tink:registry",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
    ],
)

# Android libraries

android_library(
    name = "streaming_aead_util-android",
    srcs = ["StreamingAeadUtil.java"],
    deps = ["//proto:common_java_proto_lite"],
)

android_library(
    name = "streaming_aead_key_templates-android",
    srcs = ["StreamingAeadKeyTemplates.java"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager-android",
        ":aes_gcm_hkdf_streaming_key_manager-android",
        "//proto:aes_ctr_hmac_streaming_java_proto_lite",
        "//proto:aes_gcm_hkdf_streaming_java_proto_lite",
        "//proto:common_java_proto_lite",
        "//proto:hmac_java_proto_lite",
        "//proto:tink_java_proto_lite",
    ],
)

android_library(
    name = "streaming_aead_config-android",
    srcs = ["StreamingAeadConfig.java"],
    deps = [
        ":aes_ctr_hmac_streaming_key_manager-android",
        ":aes_gcm_hkdf_streaming_key_manager-android",
        ":streaming_aead_wrapper-android",
        "//proto:config_java_proto_lite",
        "//src/main/java/com/google/crypto/tink/config:tink_fips-android",
    ],
)

android_library(
    name = "seekable_byte_channel_decrypter-android",
    srcs = ["SeekableByteChannelDecrypter.java"],
    deps = [
        "//src/main/java/com/google/crypto/tink:primitive_set-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "@maven//:com_google_code_findbugs_jsr305",
    ],
)

android_library(
    name = "input_stream_decrypter-android",
    srcs = ["InputStreamDecrypter.java"],
    deps = [
        "//src/main/java/com/google/crypto/tink:primitive_set-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "@maven//:com_google_code_findbugs_jsr305",
    ],
)

android_library(
    name = "streaming_aead_helper-android",
    srcs = ["StreamingAeadHelper.java"],
    deps = [
        ":input_stream_decrypter-android",
        ":readable_byte_channel_decrypter-android",
        ":seekable_byte_channel_decrypter-android",
        "//src/main/java/com/google/crypto/tink:primitive_set-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
    ],
)

android_library(
    name = "streaming_aead_factory-android",
    srcs = ["StreamingAeadFactory.java"],
    deps = [
        ":streaming_aead_wrapper-android",
        "//src/main/java/com/google/crypto/tink:registry-android",
        "//src/main/java/com/google/crypto/tink:registry_cluster-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
    ],
)

android_library(
    name = "aes_gcm_hkdf_streaming_key_manager-android",
    srcs = ["AesGcmHkdfStreamingKeyManager.java"],
    deps = [
        ":streaming_aead_util-android",
        "//proto:aes_gcm_hkdf_streaming_java_proto_lite",
        "//proto:common_java_proto_lite",
        "//proto:tink_java_proto_lite",
        "//src/main/java/com/google/crypto/tink:key_template-android",
        "//src/main/java/com/google/crypto/tink:key_type_manager-android",
        "//src/main/java/com/google/crypto/tink:registry-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "//src/main/java/com/google/crypto/tink/subtle:aes_gcm_hkdf_streaming",
        "//src/main/java/com/google/crypto/tink/subtle:random",
        "//src/main/java/com/google/crypto/tink/subtle:validators",
        "@com_google_protobuf//:protobuf_javalite",
    ],
)

android_library(
    name = "aes_ctr_hmac_streaming_key_manager-android",
    srcs = ["AesCtrHmacStreamingKeyManager.java"],
    deps = [
        ":streaming_aead_util-android",
        "//proto:aes_ctr_hmac_streaming_java_proto_lite",
        "//proto:common_java_proto_lite",
        "//proto:hmac_java_proto_lite",
        "//proto:tink_java_proto_lite",
        "//src/main/java/com/google/crypto/tink:key_template-android",
        "//src/main/java/com/google/crypto/tink:key_type_manager-android",
        "//src/main/java/com/google/crypto/tink:registry-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "//src/main/java/com/google/crypto/tink/subtle:aes_ctr_hmac_streaming",
        "//src/main/java/com/google/crypto/tink/subtle:random",
        "//src/main/java/com/google/crypto/tink/subtle:validators",
        "@com_google_protobuf//:protobuf_javalite",
    ],
)

android_library(
    name = "readable_byte_channel_decrypter-android",
    srcs = ["ReadableByteChannelDecrypter.java"],
    deps = [
        "//src/main/java/com/google/crypto/tink:primitive_set-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
        "//src/main/java/com/google/crypto/tink/subtle:rewindable_readable_byte_channel",
        "@maven//:com_google_code_findbugs_jsr305",
    ],
)

android_library(
    name = "streaming_aead_wrapper-android",
    srcs = ["StreamingAeadWrapper.java"],
    deps = [
        ":streaming_aead_helper-android",
        "//src/main/java/com/google/crypto/tink:primitive_set-android",
        "//src/main/java/com/google/crypto/tink:primitive_wrapper-android",
        "//src/main/java/com/google/crypto/tink:registry-android",
        "//src/main/java/com/google/crypto/tink:streaming_aead",
    ],
)
